<?php
namespace Xcx\Controller;

use Think\Controller;
use Xcx\Common\ErrorCode;
use Xcx\Model\LoginModel;

header("Content-type: text/html; charset=utf-8");
class BaseController extends Controller{
    public $uid;
    public $session3rd;

    public function __construct()
    {
        parent::__construct();

        $session3rd = $_SERVER['HTTP_SESSION3RD'];
//        $session3rd = 'R0qMKuT88LU3dDAk';//$_SERVER['HTTP_SESSION3RD'];

        if ($session3rd == '' || $session3rd == null) {
            $this->ajaxReturn(array('code'=>ErrorCode::$NoSession,'errMsg'=>'session3rd丢失'));
        }

        //查询用户uid
        $LoginModel = new LoginModel();
        $user = $LoginModel->getLoginSession($session3rd);
        $uid = $user['uid'];
        $_SESSION['userInfo']['uid'] = $uid;
        $_SESSION['userInfo']['session_key'] = $user['session_key'];

        if ($uid != null && $uid != '') {
            $this->uid = $uid;
            $this->session3rd = $session3rd;
        } else {
            $this->ajaxReturn(array('code'=>ErrorCode::$NoLogin,'errMsg'=>'未登录'));
        }
    }
}